package com.zzsz.cf.cat.controller;

import com.zzsz.cf.cat.domain.ZzwCategory;
import com.zzsz.cf.cat.service.IcatService;
import com.zzsz.common.core.controller.BaseController;
import com.zzsz.common.core.domain.AjaxResult;
import com.zzsz.common.core.page.TableDataInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * --- 就那样---
 *
 * @author zzw
 * @date 2025/9/1
 * @desc
 */
@RestController
@RequestMapping("/cf/cat")
@Slf4j
public class CatController  extends BaseController {
    /**
     * 查询分类列表
     */
    @Autowired
    private IcatService catService ;
    @GetMapping("/list")
    public TableDataInfo listCat (ZzwCategory zzwCategory) {

        //开始分页
        startPage();
        // log.debug("前端带来的查看分类的参数列表{}",zzwCategory);
        //查询分类列表
        List<ZzwCategory> list =catService.selectCatList(zzwCategory);
        return getDataTable(list);
    }
    // 新增分类
    @PostMapping("/add")
    public AjaxResult addCat(@RequestBody ZzwCategory zzwCategory) {
        return toAjax(catService.insertZzwCategory(zzwCategory));
    }
    // 批量删除分类
    @PostMapping("/delete")
    public AjaxResult deleteCat(@RequestBody List<Long> ids) {
        return toAjax(catService.deleteCat(ids));
    }
    // 修改分类
    @PostMapping("/update")
    public AjaxResult updateCat(@RequestBody ZzwCategory zzwCategory) {
        return toAjax(catService.updateZzwCategory(zzwCategory));
    }
}